#version 460 core
#define GLSLIFY 1

#define GLSLIFY 1
#define PROJECT_MATRIX

layout(std140, set=0, binding=0) uniform U_Matrix {
	mat4 mat_ProjecView;
};

layout(std140, column_major, binding = 1) uniform U2_Matrix {
	//边界
	vec2 m_Scale;
	vec2 m_Loc;
	//顶点总数量一半
	int m_GradientNum;
	int vertNum;
};

// 位置  大小 缩放和深度
layout(std430, column_major, binding = 2) readonly buffer U1_Matrix {
	//vec4 mat_Model[];
	//mat4x2 m_LP_SD;
	mat3x2 m_LP_SD[];
};

#define GLSLIFY 1
#define VERT_OUT

layout(location = 0) out vec4 vColor;
out gl_PerVertex {
	vec4	gl_Position;
	float	gl_PointSize;
};

layout(location = 1) out vec2 vUV;

vec2 pos[4] = {vec2(0.0, 0.0), vec2(1.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0)};
//vec2 pos[4] = {vec2(0.0, 0.0), vec2(100.0, 0.0), vec2(0.0, 100.0), vec2(100.0, 100.0)};
void main(void){
	mat3x2 mat = m_LP_SD[gl_InstanceIndex];

	vUV = pos[gl_VertexIndex];
	vec4 v = vec4(0.0, 0.0, 0.0, 1.0);
	//（顶点坐标*比例） + （大小*顶点权重）
	//v.xy = (pos[gl_VertexIndex] * mat[2].x) + mat[1];
	v.xy = pos[gl_VertexIndex] * mat[2].x + mat[1]*pos[gl_VertexIndex];
	
	
	v.xy += mat[0];
	v.xy *= m_Scale;
	v.xy += m_Loc;
	
	v.z = mat[2].y;
	gl_Position = mat_ProjecView * v;
	
	//gl_PointSize = 4.0;
}

